package cn.regexp.seckill.web.controller;

import cn.regexp.common.core.domain.SeckillProductVo;
import cn.regexp.common.core.web.Result;
import cn.regexp.seckill.service.ISeckillProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Regexpei
 * @date 2024/7/5 23:22
 * @description 秒杀商品控制器
 */
@Slf4j
@RequestMapping("/seckillProduct")
@RestController
public class SeckillProductController {

    @Autowired
    private ISeckillProductService seckillProductService;

    @PostMapping("/selectByType")
    public Result<List<SeckillProductVo>> selectByType(@RequestParam("time") int time) {
        // 查询秒杀商品并返回
        return Result.success(seckillProductService.selectByType(time));
    }

    @GetMapping("/queryByTime")
    public Result<List<SeckillProductVo>> queryByTime(int time) {
        // 查询秒杀商品并返回
        return Result.success(seckillProductService.queryByTime(time));
    }

    @GetMapping("/find")
    public Result<SeckillProductVo> find(int time, Long seckillId) {
        return Result.success(seckillProductService.find(time, seckillId));
    }
}
